Solved issue! fix the the version of Package.resolved to 2, then you can use agvtool normally.
Steps:
Resolve package dependencies manually. This will recreate Package.resolved (observe that version is 3 at the end of file)
Modify changing version from 3 to 2 (save)
Build or Run normally and use your scripts in Run Phase or Post-action in your scheme.